<?php
namespace Common\Models;
use Common\BaseModel;
class Article extends BaseModel
{
	public $res;
	public $expire;
	public function getSource()
		    {
				return "f_articles";
    }
	public function initialize()
	{
		 parent::initialize();
		$this->res['res']=false;
		 $this->expire=60*60*20;
        $this->hasOne("images", "File", "id");
	}

    public function getList($param){
		$page = isset($params['page']) ? intval($params['page']) : 0;
		$size = isset($params['pageSize']) ? intval($params['pageSize']) : 10;
        $condetion='published=1 ';
	    if(isset($param['type']) && !empty($param['type'])){
            $condetion .=' and article_category_id='.$param['type'];
        }
		$a['conditions']=$condetion;
		$a['order']='id desc';
		$a['limit'] = $size;
		$a['offset'] = $page;
        $listObj = $this::find($a)->toarray();
        return $listObj;
    }

	public function FindByid($id){
		$res=$this->findFirst($id);
        $res->images=$this->fileUrl.'/'.$res->File->path;
		if(empty($res)){
		    return false;
		}else{
		    return	$res;
		}
	}



    public function find_first_by_images($images){
        $res=$this->findFirstByImages($images);
        if($res){
            return	true;
        }else{
            return false;
        }
    }



}
